import type { Router } from 'vue-router';
import { createDiscreteApi } from 'naive-ui';

const { loadingBar } = createDiscreteApi(
  ['loadingBar'],
);

export default (router: Router) => {
  router.beforeEach(_ => {
    loadingBar.start();
  });

  router.afterEach(_ => {
    loadingBar.finish();
  });

  router.onError(_ => {
    loadingBar.finish();
  });
};
